<template>
	<view class="main_bg">
		<app-header title="评价"></app-header>
		<view class="card" :style="{
				'height':scrollHeight
		}">
			<view class="cell">
				<view class="label">维修记录编号：</view>
				<view class="value"> {{info.device_sns}}</view>
			</view>
			<view class="cell">
				<view class="label">维修人员：</view>
				<view class="value"> {{info.name_f}}</view>
			</view>

			<view class="cell">
				<view class="label">星级评价</view>
				<view class="value"><u-rate count="5" v-model="form.evaluate_xing" inactiveColor="#AAAAAA"
						activeColor="#F68C4F"></u-rate></view>
			</view>
			<view class="cell">
				<view class="label">文字评价：</view>
			</view>
			<view class="textarea">
				<textarea v-model="form.evaluate_msg" placeholder="请输入"></textarea>
			</view>

			<view class="flex-c">
				<view class="btn flex-c" @click="onSubmit()">提交</view>

			</view>






		</view>

	</view>
</template>

<script>
	const systemInfo = uni.getSystemInfoSync();
	const safeArea = systemInfo.safeArea;
	export default {
		name: "deviceCard",

		data() {
			return {
				id: 0,
				info: {},
				form: {},
			};
		},
		computed: {
			scrollHeight() {
				return 'calc(100vh - ' + safeArea.top + 'px - 44px  - 102rpx)'
			},
			imgCount() {
				return (imgs) => {
					const list = imgs ? imgs.split('|') : []
					return list.length
				}
			},
			imageList() {
				return (imgs) => {
					console.log(imgs)
					const list = imgs ? imgs.split('|') : []
					return list
				}
			}
		},
		onLoad(options) {
			this.id = options.id
			this.$set(this.form, 'id', options.id)
			this.getInfo()
		},
		methods: {


			getInfo() {
				this.$http.post('/data/api.auth.User/maintenanceView', {
					id: this.id,
				}).then(res => {
					this.info = res.data
				}).catch(() => {

				})
			},
			onSubmit() {
				if (!this.form.evaluate_xing) {
					this.$func.tips('请选择星级评价')
					return
				}
				this.$http.post('/data/api.auth.User/maintenanceEvaluate', {
					...this.form
				}).then(async (res) => {
					this.$func.tips('评价成功')
					uni.$emit("evaluate", {
						id: this.id
					});
					this.$func.toBack()
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.card {
		border-radius: 20px;
		background-color: #FFFFFF;
		margin: 20rpx;
		padding: 20rpx 30rpx;
	}

	.textarea {
		background-color: #F5F5F5;
		border-radius: 10rpx;
		padding: 20rpx;
	}

	.line {
		background-color: #E9E9E9;
		height: 1px;
		margin: 15rpx 0;
	}

	.icon {
		transition-duration: 0.3s;
		width: 40rpx;
		height: 40rpx;

		&.open {
			transform: rotate(180deg);
		}
	}

	.imgs_list {
		padding: 5px 0;
		justify-content: flex-start;

		.imgs_son {
			margin: 0 8px 0 0;
			border-radius: 4px;
			overflow: hidden;
		}
	}

	.cell {
		// height: 60rpx;

		.label {
			color: #333333;
		}

		.value {
			color: #ADADAD;
		}
	}

	.btn {
		width: 330rpx;
		height: 80rpx;
		background-color: #4F6FF6;
		margin-top: 100rpx;

		border-radius: 10rpx;
		font-size: 30rpx;

		color: #FFFFFF;
		margin-left: 10rpx;
	}
</style>